package com.shenmazong.serverapisafe.filter;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @program: server-java-demo
 * @description: GlobalExceptionHandler
 * @author: 亮子说编程
 * @create: 2020-12-01 14:17
 **/

@ControllerAdvice
public class GlobalExceptionHandler {

    //空指针异常
    @ExceptionHandler(value = ApiLimitException.class)
    @ResponseBody
    public String nullPointerExceptionHandler(ApiLimitException ex) {
        ex.printStackTrace();
        return ex.getMessage();
    }
}
